package com.tdy.core;

import io.swagger.jaxrs.config.BeanConfig;

import javax.ws.rs.core.Application;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

/**
 * Created by tangdaoyuan on 15/11/26.
 */
public abstract class WebApplication extends Application {
    private Set<Class<?>> classes;
    private Set<Object> singletons;
    private Map<String, Object> properties;


    public WebApplication() {
        System.out.println("初始化");
        classes = new LinkedHashSet<Class<?>>();
        singletons = new LinkedHashSet<Object>();
        properties = new HashMap<String, Object>();

    }


    public WebApplication register(Class<?> clazz) {
        classes.add(clazz);
        return this;
    }

    public WebApplication registerClasses(Class<?>... classes) {
        for (Class clazz : classes) {
            this.classes.add(clazz);
        }
        return this;
    }

    @Override
    public Set<Class<?>> getClasses() {
        return this.classes;
    }

    @Override
    public Set<Object> getSingletons() {
        return this.singletons;
    }

    @Override
    public Map<String, Object> getProperties() {
        return this.properties;
    }
}
